<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sync.java</title>
<meta name="Generator" content="SciTE - www.Scintilla.org" />
<style type="text/css">
.S0 {
	color: #808080;
}
.S1 {
	font-family: 'Lucida Sans Typewriter';
	color: #009700;
	background: #FEFEFE;
	text-decoration: inherit;
	font-size: 9pt;
}
.S2 {
	font-family: 'Lucida Sans Typewriter';
	color: #009700;
	background: #FEFEFE;
	text-decoration: inherit;
	font-size: 9pt;
}
.S3 {
	font-family: 'Lucida Sans Typewriter';
	color: #009700;
	background: #FEFEFE;
	text-decoration: inherit;
	font-size: 9pt;
}
.S4 {
	color: #007F7F;
}
.S5 {
	font-weight: bold;
	color: #205EF3;
}
.S6 {
	color: #B1009B;
}
.S7 {
	color: #7F007F;
}
.S10 {
	font-weight: bold;
	color: #000000;
}
.S18 {
	font-family: 'Lucida Sans Typewriter';
	color: #804020;
	font-size: 9pt;
}
span {
	font-family: 'Lucida Sans Typewriter';
	color: #000000;
	font-size: 9pt;
}
</style>
</head>
<body bgcolor="#FFFFFF">
<span><span class="S3">/**</span><br />
<span class="S3">&nbsp;* Sync 2.1</span><br />
<span class="S3">&nbsp;* Copyright 2007 Zach Scrivena</span><br />
<span class="S3">&nbsp;* 2007-12-09</span><br />
<span class="S3">&nbsp;* zachscrivena@gmail.com</span><br />
<span class="S3">&nbsp;* http://syncdir.sourceforge.net/</span><br />
<span class="S3">&nbsp;*</span><br />
<span class="S3">&nbsp;* Sync performs one-way directory or file synchronization.</span><br />
<span class="S3">&nbsp;*</span><br />
<span class="S3">&nbsp;* TERMS AND CONDITIONS:</span><br />
<span class="S3">&nbsp;* This program is free software: you can redistribute it and/or modify</span><br />
<span class="S3">&nbsp;* it under the terms of the GNU General Public License as published by</span><br />
<span class="S3">&nbsp;* the Free Software Foundation, either version 3 of the License, or</span><br />
<span class="S3">&nbsp;* (at your option) any later version.</span><br />
<span class="S3">&nbsp;*</span><br />
<span class="S3">&nbsp;* This program is distributed in the hope that it will be useful,</span><br />
<span class="S3">&nbsp;* but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br />
<span class="S3">&nbsp;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the</span><br />
<span class="S3">&nbsp;* GNU General Public License for more details.</span><br />
<span class="S3">&nbsp;*</span><br />
<span class="S3">&nbsp;* You should have received a copy of the GNU General Public License</span><br />
<span class="S3">&nbsp;* along with this program. &nbsp;If not, see &lt;http://www.gnu.org/licenses/&gt;.</span><br />
<span class="S3">&nbsp;*/</span><br />
<br />
<span class="S5">package</span><span class="S0"> </span>sync<span class="S10">;</span><br />
<br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>io<span class="S10">.</span>Console<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>io<span class="S10">.</span>File<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>io<span class="S10">.</span>PrintWriter<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>ArrayDeque<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>ArrayList<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Calendar<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Collections<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Date<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Deque<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>LinkedList<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>List<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Locale<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Map<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>Scanner<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>TreeMap<span class="S10">;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.</span>regex<span class="S10">.</span>PatternSyntaxException<span class="S10">;</span><br />
<br />
<br />
<span class="S3">/**</span><br />
<span class="S3">&nbsp;* Sync performs one-way directory or file synchronization.</span><br />
<span class="S3">&nbsp;*/</span><br />
<span class="S5">public</span><span class="S0"> </span><span class="S5">class</span><span class="S0"> </span>Sync<br />
<span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/******************************************</span><br />
<span class="S3">&nbsp; &nbsp;  * CONSTANTS AND MISCELLANEOUS PARAMETERS *</span><br />
<span class="S3">&nbsp; &nbsp;  ******************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** constant: program title */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>PROGRAM_TITLE<span class="S0"> </span><span class="S10">=</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"Sync 2.1 &nbsp;&nbsp;Copyright 2007 Zach Scrivena &nbsp;&nbsp;2007-12-09"</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** constant: time format string (yyyy-MM-dd HH:mm:ss.SSS) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>TIME_FORMAT_STRING<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"%1$tF %1$tT.%1$tL"</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: true if this is a Windows OS, false otherwise */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/******************************</span><br />
<span class="S3">&nbsp; &nbsp;  * SYNCHRONIZATION PARAMETERS *</span><br />
<span class="S3">&nbsp; &nbsp;  ******************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: simulate only; do not modify target (default = false) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>simulateOnly<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: ignore warnings; do not pause (default = false) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>ignoreWarnings<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: canonical full pathname of log file (default = null) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>logName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: log file PrintWriter (default = null) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span>PrintWriter<span class="S0"> </span>log<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: standard output */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span>PrintWriter<span class="S0"> </span>stdout<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: standard error */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span>PrintWriter<span class="S0"> </span>stderr<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: do not recurse into subdirectories (default = false) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>noRecurse<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** enum type: synchronization mode (DIRECTORY, FILE) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>enum<span class="S0"> </span>SyncMode<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>DIRECTORY<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>FILE<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: synchronization mode (DIRECTORY, FILE) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>SyncMode<span class="S0"> </span>syncMode<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: match file/directory name (default = true) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>matchName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: match file/directory size (always true) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>matchSize<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: match file/directory last-modified time (default = true) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>matchTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: match file/directory CRC-32 checksum (default = true) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>matchCrc<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: time-tolerance in milliseconds for file-matching (default = 0) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">long</span><span class="S0"> </span>matchTimeTolerance<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0L</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: string representation of match attributes, e.g. "(name,size,time,CRC)" */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>matchNstcString<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** partial FileUnit comparator for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>FileUnitComparator<span class="S0"> </span>matchFileUnitComparator<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** partial FileUnit comparator for searching (should be a "truncated" version of Sync.matchFileUnitComparator) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>FileUnitComparator<span class="S0"> </span>searchFileUnitComparator<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** name-only FileUnit comparator */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>FileUnitComparator<span class="S0"> </span>nameOnlyFileUnitComparator<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: canonical full pathname of source file/directory (ends with a separator for a directory) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>sourceName<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: canonical full pathname of target file/directory (ends with a separator for a directory) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>targetName<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: source file/directory (canonical full pathname) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>File<span class="S0"> </span>source<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: target file/directory (canonical full pathname) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>File<span class="S0"> </span>target<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: default action on renaming matched files (default = '\0') */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: default action on synchronizing time of matched files (default = '\0') */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: default action on deleting unmatched target files/directories (default = '\0') */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: default action on overwriting existing target files (default = '\0') */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: filter for source file/directory names (default = null) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>FilterNode<span class="S0"> </span>sourceFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: filter for target file/directory names (default = null) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>FilterNode<span class="S0"> </span>targetFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: filter relative pathnames instead of filenames (default = false) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>filterRelativePathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** parameter: use lower case names for filtering (default = false) */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>filterLowerCase<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/*********************</span><br />
<span class="S3">&nbsp; &nbsp;  * REPORT STATISTICS *</span><br />
<span class="S3">&nbsp; &nbsp;  *********************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/** statistic: number of warnings encountered */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>reportNumWarnings<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Main entry point for the Sync program.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> args</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Command-line argument strings</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">public</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>main<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S10">[]</span><span class="S0"> </span>args<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* initialize standard output and error streams */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Console<span class="S0"> </span>console<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>System<span class="S10">.</span>console<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>console<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stdout<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>PrintWriter<span class="S10">(</span>System<span class="S10">.</span>out<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stderr<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>PrintWriter<span class="S10">(</span>System<span class="S10">.</span>err<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stdout<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>console<span class="S10">.</span>writer<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stderr<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>console<span class="S10">.</span>writer<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display program title */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>PROGRAM_TITLE<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* exit status code to be reported to the OS when exiting (default = 0) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>exitCode<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* determine if this is a Windows OS */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>System<span class="S10">.</span>getProperty<span class="S10">(</span><span class="S6">"os.name"</span><span class="S10">).</span>toUpperCase<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">).</span>contains<span class="S10">(</span><span class="S6">"WINDOWS"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>File<span class="S10">.</span>separatorChar<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\\'</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process command-line arguments and configure synchronization parameters */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>processArguments<span class="S10">(</span>args<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printLog<span class="S10">(</span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>PROGRAM_TITLE<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* perform synchronization */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">switch</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">case</span><span class="S0"> </span>DIRECTORY<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncDirectory<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">case</span><span class="S0"> </span>FILE<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncFile<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\nSync is done!\n\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>TerminatingException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* terminating exception thrown; proceed to abort program */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* (this should be the only place where a TerminatingException is caught) */</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>exitCode<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>e<span class="S10">.</span>getExitCode<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>exitCode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* abnormal termination; SyncIO.print error message */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printToErr<span class="S10">(</span><span class="S6">"\n\nERROR: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>e<span class="S10">.</span>getMessage<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\nSync aborted.\n\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* catch all other exceptions; proceed to abort program */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printToErr<span class="S10">(</span><span class="S6">"\n\nERROR: An unexpected error has occurred:\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>exitCode<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">1</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\nSync aborted.\n\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">finally</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* perform clean-up before exiting */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stdout<span class="S10">.</span>flush<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>stderr<span class="S10">.</span>flush<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>log<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>log<span class="S10">.</span>flush<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>log<span class="S10">.</span>close<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>log<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>System<span class="S10">.</span>exit<span class="S10">(</span>exitCode<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Process command-line arguments and configure synchronization parameters.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> args</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Command-line argument strings</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>processArguments<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S10">[]</span><span class="S0"> </span>args<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>howHelp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">"\nTo display help, run Sync without any command-line arguments."</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* SyncIO.print usage documentation, if no arguments */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>args<span class="S10">.</span>length<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>printUsage<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S5">null</span><span class="S10">,</span><span class="S0"> </span><span class="S4">0</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* check if sufficient arguments */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>args<span class="S10">.</span>length<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span><span class="S4">2</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Insufficient arguments:\nThe source and target directories/files must be specified."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process source directory/file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>args<span class="S10">[</span>args<span class="S10">.</span>length<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">2</span><span class="S10">]);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getCanonicalFile<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Source \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" is not a valid directory/file:\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process target directory/file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>args<span class="S10">[</span>args<span class="S10">.</span>length<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">1</span><span class="S10">]);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getCanonicalFile<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Target \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" is not a valid directory/file:\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* determine synchronization mode */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source is a directory; must check that target is NOT a file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">!</span>Sync<span class="S10">.</span>target<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Target \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" is a file.\nFor DIRECTORY synchronization, the target (if it exists) must also be a directory."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* DIRECTORY synchronization */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>SyncMode<span class="S10">.</span>DIRECTORY<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>source<span class="S10">.</span>exists<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source is a file; must check that target is NOT a directory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Target \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" is a directory.\nFor FILE synchronization, the target (if it exists) must also be a file."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* FILE synchronization */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>SyncMode<span class="S10">.</span>FILE<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">());</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">());</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source does not exist */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Source \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" does not exist."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* initialize filename filters */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>String<span class="S10">&gt;</span><span class="S0"> </span>includeSource<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>String<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>String<span class="S10">&gt;</span><span class="S0"> </span>excludeSource<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>String<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>String<span class="S10">&gt;</span><span class="S0"> </span>includeTarget<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>String<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>String<span class="S10">&gt;</span><span class="S0"> </span>excludeTarget<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>String<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>regexFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process command-line switches */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">,</span><span class="S0"> </span>n<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>args<span class="S10">.</span>length<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">2</span><span class="S10">;</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span>n<span class="S10">;</span><span class="S0"> </span>i<span class="S10">++)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>sw<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>args<span class="S10">[</span>i<span class="S10">];</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--simulate"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-s"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* simulate only; do not modify target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>simulateOnly<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>ignoreWarnings<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--ignorewarnings"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* ignore warnings; do not pause &nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>ignoreWarnings<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--log"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-l"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create log file "sync.yyyyMMdd-HHmmss.log" */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --log can be specified at most once."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>timestamp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>String<span class="S10">.</span>format<span class="S10">(</span><span class="S6">"%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS"</span><span class="S10">,</span><span class="S0"> </span>Calendar<span class="S10">.</span>getInstance<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">));</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>File<span class="S0"> </span>f<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span><span class="S6">"sync."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>timestamp<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">".log"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>f<span class="S10">.</span>exists<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* find an unused file name */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">long</span><span class="S0"> </span>k<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><span class="S0"> </span>k<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span>Long<span class="S10">.</span>MAX_VALUE<span class="S10">;</span><span class="S0"> </span>k<span class="S10">++)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>f<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span><span class="S6">"sync."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>timestamp<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>k<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">".log"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>f<span class="S10">.</span>exists<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>f<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* use this unused name */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>f<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to create an unused filename for log file:\nRan out of suffixes n in \"sync."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>timestamp<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">".n.log\"; try specifying a filename, e.g. --log:\"record.txt\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>f<span class="S10">.</span>getCanonicalPath<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to create log file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>f<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--log:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-l:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create log file with the specified name */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --log can be specified at most once."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --log parameter:\nA log filename must be specified, e.g. --log:\"record.txt\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>File<span class="S0"> </span>f<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>a<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>f<span class="S10">.</span>exists<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Log file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>f<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" already exists:\nA nonexistent file must be specified."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>f<span class="S10">.</span>getCanonicalPath<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to create log file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>f<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--norecurse"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-r"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* do not recurse into subdirectories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>noRecurse<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--noname"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-n"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* do not use filename for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--notime"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-t"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* do not use last-modified time for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--nocrc"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)||</span><span class="S0"> </span><span class="S6">"-c"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* do not use CRC-32 checksum for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--time:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* use specified time-tolerance (in milliseconds) for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --time parameter:\nTime-tolerance (in milliseconds) must be a nonnegative integer, e.g. --time:2000."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Long<span class="S10">.</span>parseLong<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">-</span><span class="S4">1L</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span><span class="S4">0L</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Invalid --time parameter \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>a<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\nTime-tolerance (in milliseconds) must be a nonnegative integer, e.g. --time:2000."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--rename:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* rename matched target files? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --rename parameter:\nParameter must be \"y\" or \"n\", e.g. --rename:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"y"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"n"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Invalid --rename parameter \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>a<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\nParameter must be \"y\" or \"n\", e.g. --rename:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--synctime:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* synchronize time of matched target files? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --synctime parameter:\nParameter must be \"y\" or \"n\", e.g. --synctime:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"y"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"n"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Invalid --synctime parameter \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>a<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\nParameter must be \"y\" or \"n\", e.g. --synctime:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--overwrite:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* overwrite existing target files? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --overwrite parameter:\nParameter must be \"y\" or \"n\", e.g. --overwrite:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"y"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"n"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Invalid --overwrite parameter \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>a<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\nParameter must be \"y\" or \"n\", e.g. --overwrite:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--delete:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* delete unmatched target files/directories? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --delete can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --delete parameter:\nParameter must be \"y\" or \"n\", e.g. --delete:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"y"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"n"</span><span class="S10">.</span>equals<span class="S10">(</span>a<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Invalid --delete parameter \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>a<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\nParameter must be \"y\" or \"n\", e.g. --delete:y."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--force"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* equivalent to the combination: "--rename:y --synctime:y --overwrite:y --delete:y" */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--path"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-p"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* filter relative pathnames instead of filenames (e.g. "work\report\jan.txt" instead of "jan.txt") */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --path can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--lower"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S6">"-w"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* use lower case names for filtering (e.g. "HelloWorld2007.JPG" ---&gt; "helloworld2007.jpg") */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --lower can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>filterLowerCase<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"--regex"</span><span class="S10">.</span>equals<span class="S10">(</span>sw<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span><span class="S1">/* use REGEX instead of GLOB filename filters */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--include:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-i:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* include source and target files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --include can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --include parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --include:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includeSource<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includeTarget<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--exclude:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-x:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* exclude source and target files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --exclude can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --exclude parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --exclude:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludeSource<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludeTarget<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--includesource:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-is:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* include source files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --includesource can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --includesource parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --includesource:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includeSource<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--excludesource:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-xs:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* exclude source files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --excludesource can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --excludesource parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --excludesource:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludeSource<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--includetarget:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-it:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* include target files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --includetarget can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --includetarget parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --includetarget:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includeTarget<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"--excludetarget:"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>sw<span class="S10">.</span>startsWith<span class="S10">(</span><span class="S6">"-xt:"</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* exclude target files/directories with names matching specified GLOB/REGEX expression */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>DIRECTORY<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --excludetarget can be used for only DIRECTORY synchronization."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sw<span class="S10">.</span>substring<span class="S10">(</span>sw<span class="S10">.</span>indexOf<span class="S10">(</span><span class="S7">':'</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>a<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Empty --excludetarget parameter:\nA GLOB (or REGEX) expression must be specified, e.g. --excludetarget:\"*.{mp3,jpg}\"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludeTarget<span class="S10">.</span>add<span class="S10">(</span>a<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* invalid switch */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sw<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" is not a valid switch."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process source filename filters, if any */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>includeSource<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>excludeSource<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>NOR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>excludeSource<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>excludeSource<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>OR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>includeSource<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilterNode<span class="S0"> </span>includes<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>OR<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilterNode<span class="S0"> </span>excludes<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>NOR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>includeSource<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includes<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>excludeSource<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludes<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>AND<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>addFilter<span class="S10">(</span>includes<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>addFilter<span class="S10">(</span>excludes<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process target filename filters, if any */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>includeTarget<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>excludeTarget<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>NOR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>excludeTarget<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>excludeTarget<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>OR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>includeTarget<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilterNode<span class="S0"> </span>includes<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>OR<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilterNode<span class="S0"> </span>excludes<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>NOR<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>includeTarget<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>includes<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>String<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>excludeTarget<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>excludes<span class="S10">.</span>addFilter<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>REGEX<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>FilterNode<span class="S10">.</span>FilterType<span class="S10">.</span>GLOB<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>false<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>isWindowsOperatingSystem<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>s<span class="S10">.</span>replace<span class="S10">(</span><span class="S6">"/"</span><span class="S10">,</span><span class="S0"> </span><span class="S6">"\\\\"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>s<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>PatternSyntaxException<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to compile the specified "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>regexFilter<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"REGEX"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"GLOB"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" expression \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilterNode<span class="S10">(</span>FilterNode<span class="S10">.</span>LogicType<span class="S10">.</span>AND<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>addFilter<span class="S10">(</span>includes<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>addFilter<span class="S10">(</span>excludes<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* check certain combinations of switches */</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterRelativePathname<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --path cannot be used when no filter is specified."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --lower cannot be used when no filter is specified."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --rename cannot be used in simulation mode."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --synctime cannot be used in simulation mode."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --overwrite cannot be used in simulation mode."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Switch --delete cannot be used in simulation mode."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnOverwrite<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* prepare log file, if specified */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>log<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>PrintWriter<span class="S10">(</span>Sync<span class="S10">.</span>logName<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Failed to create log file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>getExceptionMessage<span class="S10">(</span>e<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>howHelp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* disable filename matching for FILE synchronization */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>syncMode<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>Sync<span class="S10">.</span>syncMode<span class="S10">.</span>FILE<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create string representation of match attributes, e.g. "(name,size,time,crc)" */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchNstcString<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>getNstcString<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchName<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchSize<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTime<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchCrc<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create partial FileUnit comparator for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchFileUnitComparator<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnitComparator<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchName<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchSize<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTime<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchCrc<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create partial FileUnit comparator for searching (should be a "truncated" version of Sync.matchFileUnitComparator) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>searchFileUnitComparator<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnitComparator<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>matchName<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchSize<span class="S10">,</span><span class="S0"> </span>false<span class="S10">,</span><span class="S0"> </span>false<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create name-only FileUnit comparator */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>nameOnlyFileUnitComparator<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnitComparator<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>true<span class="S10">,</span><span class="S0"> </span>false<span class="S10">,</span><span class="S0"> </span>false<span class="S10">,</span><span class="S0"> </span>false<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Perform DIRECTORY synchronization from Sync.source to Sync.target.</span><br />
<span class="S3">&nbsp; &nbsp;  * The source must be an existing directory; the target must be a directory if it exists.</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>syncDirectory<span class="S10">()</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>StringBuilder<span class="S0"> </span>s<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>StringBuilder<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nDIRECTORY SYNCHRONIZATION"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">" (SIMULATION MODE)"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display log file, if any */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>log<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nLog file: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display source and target directories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nSource directory: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nTarget directory: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display file-matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nFile-matching attributes: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>matchNstcString<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0L</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">", with "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"-millisecond time-tolerance\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display source and target file/directorry filters, if any */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nSource file/directory filter: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>toString<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nTarget file/directory filter: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>toString<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nFilter mode: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"lower-case "</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">""</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"relative pathname"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"filename"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span>s<span class="S10">.</span>toString<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* validate source and target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">.</span>equals<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"The source directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" cannot be the same as the target directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceName<span class="S10">.</span>startsWith<span class="S10">(</span>Sync<span class="S10">.</span>targetName<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"The source directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" cannot be a subdirectory of the target directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetName<span class="S10">.</span>startsWith<span class="S10">(</span>Sync<span class="S10">.</span>sourceName<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"The target directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" cannot be a subdirectory of the source directory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>sourceNameLength<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S10">.</span>length<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>targetNameLength<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S10">.</span>length<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* report statistics */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumSourceDirsScanned<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumSourceFilesScanned<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumTargetFilesScanned<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumSourceFilesMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumSyncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumSyncTimeSuccess<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumRenameOperations<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumRenameOperationsSuccess<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumUnmatchedSourceFiles<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumUnmatchedSourceFilesCopied<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumUnmatchedTargetFilesDirs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>reportNumUnmatchedTargetFilesDirsDeleted<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* perform a DFS synchronization of the subdirectories using two stacks: */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* - contentStack contains directories whose contents are to be synced &nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* - timeStack contains directories whose time should be synced after &nbsp;&nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* &nbsp;&nbsp;processing all their contents &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Deque<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>contentStack<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayDeque<span class="S10">&lt;</span>FilePair<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Deque<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>timeStack<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayDeque<span class="S10">&lt;</span>FilePair<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>marker<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span><span class="S5">null</span><span class="S10">,</span><span class="S0"> </span><span class="S5">null</span><span class="S10">);</span><span class="S0"> </span><span class="S2">// special marker</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>contentStack<span class="S10">.</span>push<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">));</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncNextDirectory<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">while</span><span class="S0"> </span><span class="S10">(!</span>contentStack<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* get subdirectory-pair for synchronizing contents */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>pair<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>contentStack<span class="S10">.</span>pop<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* check for special marker */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>pair<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>marker<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/**************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * SYNC LAST-MODIFIED TIME OF TARGET SUBDIRECTORY *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  **************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>timePair<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timeStack<span class="S10">.</span>pop<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>timeSourceDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timePair<span class="S10">.</span>source<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>timeTargetDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timePair<span class="S10">.</span>target<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>timeSourceDir<span class="S10">.</span>isDirectory<span class="S10">()</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span>timeTargetDir<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">long</span><span class="S0"> </span>sourceTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timeSourceDir<span class="S10">.</span>lastModified<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">long</span><span class="S0"> </span>targetTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timeTargetDir<span class="S10">.</span>lastModified<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create the target subdirectory only if the times are different, and */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* the target's name matches the filter (if specified) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetTime<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>sourceTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>timeTargetDirName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>timeTargetDir<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>String<span class="S0"> </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>timeTargetDirName<span class="S10">.</span>length<span class="S10">()</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>targetNameLength<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is the base target directory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">""</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">?</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>timeTargetDirName<span class="S10">.</span>substring<span class="S10">(</span>targetNameLength<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>timeTargetDir<span class="S10">.</span>getName<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>name<span class="S10">.</span>toLowerCase<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>matches<span class="S10">(</span>name<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>success<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>timeTargetDir<span class="S10">.</span>setLastModified<span class="S10">(</span>sourceTime<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>success<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to set last-modified time of target subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>timeTargetDir<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\":\n "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>String<span class="S10">.</span>format<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>TIME_FORMAT_STRING<span class="S10">,</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>Date<span class="S10">(</span>targetTime<span class="S10">))</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>String<span class="S10">.</span>format<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>TIME_FORMAT_STRING<span class="S10">,</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>Date<span class="S10">(</span>sourceTime<span class="S10">))</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*********************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (1) DISPLAY RELATIVE PATHNAME *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *********************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>sourceDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>pair<span class="S10">.</span>source<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>sourceDirName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>sourceDir<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* target subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>targetDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>pair<span class="S10">.</span>target<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>targetDirName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>targetDir<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* relative pathname of the subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>relativePathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sourceDirName<span class="S10">.</span>substring<span class="S10">(</span>sourceNameLength<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\nSUBDIRECTORY: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S10">(</span>relativePathname<span class="S10">.</span>isEmpty<span class="S10">()</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S10">(</span><span class="S6">"."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>relativePathname<span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetDir<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">!</span>targetDir<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"The target \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>targetDir<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" already exists but is not a directory; could it be a file?\nThis subdirectory will be ignored."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*******************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (2) GET CONTENTS OF SOURCE SUBDIRECTORY *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *******************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* get source files (filtered if necessary) and subdirectories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S10">[]</span><span class="S0"> </span>sFileList<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sourceDir<span class="S10">.</span>listFiles<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sFileList<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to get contents of source subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sourceDirName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\".\nThis subdirectory will be ignored."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sFiles<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sDirs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>File<span class="S0"> </span>f<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFileList<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnit<span class="S10">(</span>f<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>isDirectory<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sDirs<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* apply filter on file, if necessary */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>String<span class="S0"> </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">?</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">().</span>substring<span class="S10">(</span>sourceNameLength<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>name<span class="S10">.</span>toLowerCase<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>matches<span class="S10">(</span>name<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>addFile<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sFiles<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSourceDirsScanned<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSourceFilesScanned<span class="S0"> </span><span class="S10">+=</span><span class="S0"> </span>sFiles<span class="S10">.</span>size<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*******************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (3) GET CONTENTS OF TARGET SUBDIRECTORY *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *******************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* get target files and subdirectories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>tFiles<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>tDirs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetDir<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* target subdirectory already exists; get its contents */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S10">[]</span><span class="S0"> </span>tFileList<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>targetDir<span class="S10">.</span>listFiles<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>tFileList<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to get contents of target subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetDirName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\".\nThis subdirectory will be ignored."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>File<span class="S0"> </span>f<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>tFileList<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnit<span class="S10">(</span>f<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>isDirectory<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tDirs<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* apply filter on file, if necessary */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>String<span class="S0"> </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">?</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">().</span>substring<span class="S10">(</span>targetNameLength<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>name<span class="S10">.</span>toLowerCase<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>targetFilter<span class="S10">.</span>matches<span class="S10">(</span>name<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>addFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>addFile<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tFiles<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetDir<span class="S10">.</span>exists<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* target already exists, but is not a directory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Target \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>targetDir<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" already exists but is not a directory; could it be a file?"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nThis subdirectory will be ignored."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* target subdirectory does not exist; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to create it only if its name matches the filter (if specified) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>createDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>createDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>String<span class="S0"> </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetDirName<span class="S10">.</span>length<span class="S10">()</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>targetNameLength<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is the base target directory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S6">""</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>filterRelativePathname<span class="S0"> </span><span class="S10">?</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetDirName<span class="S10">.</span>substring<span class="S10">(</span>targetNameLength<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>targetDir<span class="S10">.</span>getName<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>filterLowerCase<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>name<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>name<span class="S10">.</span>toLowerCase<span class="S10">(</span>Locale<span class="S10">.</span>ENGLISH<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>sourceFilter<span class="S10">.</span>matches<span class="S10">(</span>name<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>createDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>createDir<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetDir<span class="S10">.</span>mkdirs<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>targetDir<span class="S10">.</span>isDirectory<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to create target subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetDirName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\".\nThis subdirectory will be ignored."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumTargetFilesScanned<span class="S0"> </span><span class="S10">+=</span><span class="S0"> </span>tFiles<span class="S10">.</span>size<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/**************************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (4) CHECK FOR FILE-MATCHING KEY CLASHES AMONG SOURCE FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  **************************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* sort source files by file-matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Collections<span class="S10">.</span>sort<span class="S10">(</span>sFiles<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>matchFileUnitComparator<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>FileUnit<span class="S0"> </span>w<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFiles<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* check if consecutive files have the same file-matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>w<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>matchFileUnitComparator<span class="S10">.</span>compare<span class="S10">(</span>u<span class="S10">,</span><span class="S0"> </span>w<span class="S10">)</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">0</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"File-matching key clash in source subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceDirName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\":\nThe following source files have the same "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>matchNstcString<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">":"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n [1] \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n [2] \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>w<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nThe files in this subdirectory will be ignored."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* recurse into subdirectories: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* (this block of code should be identical to the one below) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* push subdirectory-pair onto time-stack for subsequent time-sync */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>timeStack<span class="S10">.</span>push<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>sourceDir<span class="S10">,</span><span class="S0"> </span>targetDir<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>contentStack<span class="S10">.</span>push<span class="S10">(</span>marker<span class="S10">);</span><span class="S0"> </span><span class="S2">// special marker</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>noRecurse<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sDirs<span class="S10">.</span>size<span class="S10">()</span><span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">1</span><span class="S10">;</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><span class="S0"> </span>i<span class="S10">--)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>sDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sDirs<span class="S10">.</span>get<span class="S10">(</span>i<span class="S10">).</span>file<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* corresponding target subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>tDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>targetDir<span class="S10">,</span><span class="S0"> </span>sDir<span class="S10">.</span>getName<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* push subdirectory-pair onto content-stack for subsequent content-sync */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>contentStack<span class="S10">.</span>push<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>sDir<span class="S10">,</span><span class="S0"> </span>tDir<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>SyncNextDirectory<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>w<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>u<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*************************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (5) PERFORM FILE-MATCHING BETWEEN SOURCE AND TARGET FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *************************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* perform file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>uniqueMatching<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>performSourceTargetFileMatching<span class="S10">(</span>sFiles<span class="S10">,</span><span class="S0"> </span>tFiles<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* matched source files, to be time-synced or renamed if necessary */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sFilesMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* unmatched source files, to be copied */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sFilesUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* unmatched target files and subdirectories, to be deleted */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Map<span class="S10">&lt;</span>File<span class="S10">,</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>tFilesDirsUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TreeMap<span class="S10">&lt;</span>File<span class="S10">,</span>FileUnit<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process source files */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFiles<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>match<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is an unmatched source file, to be copied */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sFilesUnmatched<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is a matched source file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sFilesMatched<span class="S10">.</span>add<span class="S10">(</span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process target files */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>tFiles<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>match<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is an unmatched target file, to be deleted */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tFilesDirsUnmatched<span class="S10">.</span>put<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">,</span><span class="S0"> </span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* perform directory-matching (matching by name only) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>performSourceTargetDirMatching<span class="S10">(</span>sDirs<span class="S10">,</span><span class="S0"> </span>tDirs<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* process target directories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>tDirs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>match<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* this is an unmatched target subdirectory, to be deleted */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tFilesDirsUnmatched<span class="S10">.</span>put<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">,</span><span class="S0"> </span>u<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*******************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (6) DISPLAY MATCHED SOURCE-TARGET FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *******************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* number of matched target files to time-sync and rename */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>numSyncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>numSyncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>sFiles<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>numSourceFilesMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sFilesMatched<span class="S10">.</span>size<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n No. of source files matched: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>numSourceFilesMatched<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" of "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sFiles<span class="S10">.</span>size<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFilesMatched<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSourceFilesMatched<span class="S10">++;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display matched source-target pair and matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n [M"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSourceFilesMatched<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">":"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>sameName<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"n"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" "</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>sameSize<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"s"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" "</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>sameTime<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"t"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" "</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>sameCrc<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"c"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" "</span><span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">""</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"] \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>sameName<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">""</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S10">(</span><span class="S6">" &lt;---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>match<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">)));</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* need to sync filename of matched target file? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>u<span class="S10">.</span>sameName<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncName<span class="S10">++;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* need to sync time of matched target file? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>u<span class="S10">.</span>sameTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncTime<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* warn on poor file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>uniqueMatching<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Matching between files in source subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceDirName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" and target subdirectory \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>targetDirName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" involves arbitrarily broken ties."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*****************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (7) SYNC TIME OF MATCHED TARGET FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *****************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>numSyncTime<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Synchronizing last-modified time of "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncTime<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncTime<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file:"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files:"</span><span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Skipping last-modified time synchronization of "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncTime<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncTime<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files"</span><span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Synchronize last-modified time of "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncTime<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncTime<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"?\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>choice<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>userCharPrompt<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" &nbsp;(Y)es/(N)o/(A)lways/Neve(R): "</span><span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"YNAR"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'A'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'R'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to synchronize time of matched target files */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFilesMatched<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>t<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>u<span class="S10">.</span>match<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>t<span class="S10">.</span>sameTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* set last-modified time of the matched target file to that of the source file */</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSyncTime<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n [T"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSyncTime<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"] \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n &nbsp;"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>t<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>getTimeString<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>setFileTime<span class="S10">(</span>t<span class="S10">.</span>file<span class="S10">,</span><span class="S0"> </span>u<span class="S10">.</span>time<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* last-modified time of file was successfully set */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSyncTimeSuccess<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to set last-modified time of matched target file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>t<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/***********************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (8) RENAME MATCHED TARGET FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ***********************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>numSyncName<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Renaming "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncName<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file:"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files:"</span><span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Skipping renaming of "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncName<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files"</span><span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Rename "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>numSyncName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" matched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>numSyncName<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"file"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"files"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"?\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>choice<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>userCharPrompt<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" &nbsp;(Y)es/(N)o/(A)lways/Neve(R): "</span><span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"YNAR"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'A'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'R'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncName<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* determine actual file renaming operations */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>renamePairs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* get desired source-target rename pair */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFilesMatched<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>u<span class="S10">.</span>sameName<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>renamePairs<span class="S10">.</span>add<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>u<span class="S10">.</span>match<span class="S10">.</span>file<span class="S10">,</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>targetDir<span class="S10">,</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S10">)));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>renameOperations<span class="S0"> </span><span class="S10">=</span><span class="S0">&nbsp;</span>getRenameOperations<span class="S10">(</span>renamePairs<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to rename matched target file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FilePair<span class="S0"> </span>p<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>renameOperations<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumRenameOperations<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n [R"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumRenameOperations<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"] \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>source<span class="S10">.</span>getName<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>p<span class="S10">.</span>target<span class="S10">.</span>getName<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>renameFile<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file was successfully renamed */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumRenameOperationsSuccess<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tFilesDirsUnmatched<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to rename matched target file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/***********************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (9) COPY UNMATCHED SOURCE FILES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ***********************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>sFilesUnmatched<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>numUnmatchedSourceFiles<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sFilesUnmatched<span class="S10">.</span>size<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display unmatched source files to be copied to the target subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n No. of unmatched source files to be copied: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>numUnmatchedSourceFiles<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFilesUnmatched<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumUnmatchedSourceFiles<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n [C"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedSourceFiles<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"] \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ("</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>getSizeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">")"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* desired target file for copy operation */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>targetFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>targetDir<span class="S10">,</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>copyFile<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">,</span><span class="S0"> </span>targetFile<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file was successfully copied */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumUnmatchedSourceFilesCopied<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tFilesDirsUnmatched<span class="S10">.</span>remove<span class="S10">(</span>targetFile<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>reportWarning<span class="S10">(</span><span class="S6">"Failed to copy unmatched source file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/**************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (10) DELETE UNMATCHED TARGET FILES/DIRECTORIES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  **************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>tFilesDirsUnmatched<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>numUnmatchedTargetFilesDirs<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>tFilesDirsUnmatched<span class="S10">.</span>size<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n No. of unmatched target files/directories to be deleted: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>numUnmatchedTargetFilesDirs<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* delete unmatched target files (first pass), and subdirectories (second pass) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">boolean</span><span class="S0"> </span>isDirectory<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span><span class="S5">boolean</span><span class="S10">[]{</span>false<span class="S10">,</span><span class="S0"> </span>true<span class="S10">})</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>u<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>tFilesDirsUnmatched<span class="S10">.</span>values<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>isDirectory<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>isDirectory<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumUnmatchedTargetFilesDirs<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n [D"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedTargetFilesDirs<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"] "</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>stillExists<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">.</span>isDirectory<span class="S10">()</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>u<span class="S10">.</span>isDirectory<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to check full canonical pathname */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>String<span class="S0"> </span>pathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">try</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>pathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>u<span class="S10">.</span>file<span class="S10">.</span>getCanonicalPath<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">catch</span><span class="S0"> </span><span class="S10">(</span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>pathname<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>pathname<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span>pathname<span class="S10">.</span>equals<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">()))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>stillExists<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>stillExists<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>deleteFileDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>deleteFileDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"Skipping \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"Delete \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"?\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>choice<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>userCharPrompt<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" &nbsp;(Y)es/(N)o/(A)lways/Neve(R): "</span><span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"YNAR"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>deleteFileDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'A'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>deleteFileDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'R'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>defaultActionOnDeleteUnmatched<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>deleteFileDir<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>deleteFileDir<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file/directory was successfully deleted */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumUnmatchedTargetFilesDirsDeleted<span class="S10">++;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>reportWarning<span class="S10">(</span><span class="S6">"Failed to delete unmatched target "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>isDirectory<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">"directory"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">"file"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>trimTrailingSeparator<span class="S10">(</span>u<span class="S10">.</span>file<span class="S10">.</span>getPath<span class="S10">())</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span>u<span class="S10">.</span>isDirectory<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span>File<span class="S10">.</span>separatorChar<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">""</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file/directory does not exist anymore */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>u<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" does not exist anymore"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (11) RECURSE INTO SUBDIRECTORIES *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* push subdirectory-pair onto time-stack for subsequent time-sync */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>timeStack<span class="S10">.</span>push<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>sourceDir<span class="S10">,</span><span class="S0"> </span>targetDir<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>contentStack<span class="S10">.</span>push<span class="S10">(</span>marker<span class="S10">);</span><span class="S0"> </span><span class="S2">// special marker</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>noRecurse<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sDirs<span class="S10">.</span>size<span class="S10">()</span><span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">1</span><span class="S10">;</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><span class="S0"> </span>i<span class="S10">--)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>sDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sDirs<span class="S10">.</span>get<span class="S10">(</span>i<span class="S10">).</span>file<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* corresponding target subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>tDir<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>targetDir<span class="S10">,</span><span class="S0"> </span>sDir<span class="S10">.</span>getName<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* push subdirectory-pair onto content-stack for subsequent content-sync */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>contentStack<span class="S10">.</span>push<span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>sDir<span class="S10">,</span><span class="S0"> </span>tDir<span class="S10">));</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*********************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp;  * REPORT STATISTICS *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp;  *********************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>StringBuilder<span class="S0"> </span>report<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>StringBuilder<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nSYNCHRONIZATION REPORT"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">" warning"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" warnings"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" encountered."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of source subdirectories scanned &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSourceDirsScanned<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of source files scanned &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSourceFilesScanned<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of target files scanned &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumTargetFilesScanned<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of source files matched [M] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSourceFilesMatched<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>reportNumSyncTime<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n No. of successful time-sync operations [T] &nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumSyncTimeSuccess<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" of "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumSyncTime<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>reportNumRenameOperations<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n No. of successful file rename operations [R] &nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportNumRenameOperationsSuccess<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" of "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumRenameOperations<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>report<span class="S10">.</span>append<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of unmatched source files [C] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedSourceFiles<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" ("</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedSourceFilesCopied<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" copied)"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n No. of unmatched target files/directories [D] : "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedTargetFilesDirs<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" ("</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>reportNumUnmatchedTargetFilesDirsDeleted<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" deleted)"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span>report<span class="S10">.</span>toString<span class="S10">());</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Perform FILE synchronization from Sync.source to Sync.target.</span><br />
<span class="S3">&nbsp; &nbsp;  * The source must be an existing file; the target must be a file if it exists.</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>syncFile<span class="S10">()</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>StringBuilder<span class="S0"> </span>s<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>StringBuilder<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nFILE SYNCHRONIZATION"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">" (SIMULATION MODE)"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display log file, if any */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>log<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nLog file: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>logName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display source and target directories */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n\nSource file: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nTarget file: \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display file-matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nFile-matching attributes: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>matchNstcString<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0L</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">",\n with "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"-millisecond time-tolerance"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span>s<span class="S10">.</span>toString<span class="S10">());</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* validate source and target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">.</span>equals<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"The source file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>sourceName<span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\" cannot be the same as the target file \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>targetName<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source and target files */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>sourceFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnit<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>targetFile<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FileUnit<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">)</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>targetFile<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/***************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (1) COPY SOURCE FILE TO NONEXISTENT TARGET FILE *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ***************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* target file does not exist; proceed to copy source to target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\nTarget file does not exist\n\nCopying \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n &nbsp;---&gt; &nbsp;\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>copyFile<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file was successfully copied */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n1 file copied."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>reportWarning<span class="S10">(</span><span class="S6">"Failed to copy source file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>matchFileUnitComparator<span class="S10">.</span>compare<span class="S10">(</span>sourceFile<span class="S10">,</span><span class="S0"> </span>targetFile<span class="S10">)</span><span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/***********************************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (2) COPY UNMATCHED SOURCE FILE TO EXISTING TARGET FILE &nbsp;*</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ***********************************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* source and target files do not match; proceed to copy source to target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\nSource and target files do not match\n\nCopying \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n &nbsp;---&gt; &nbsp;\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>copyFile<span class="S10">(</span>Sync<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>error<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file was successfully copied */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n1 file copied."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>reportWarning<span class="S10">(</span><span class="S6">"Failed to copy unmatched source file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (3) SOURCE AND TARGET FILES MATCH *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\nSource and target files have the same "</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>sameName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sourceFile<span class="S10">.</span>name<span class="S10">.</span>equals<span class="S10">(</span>targetFile<span class="S10">.</span>name<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>sameSize<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">(</span>sourceFile<span class="S10">.</span>size<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>targetFile<span class="S10">.</span>size<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>sameTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">(</span>sourceFile<span class="S10">.</span>time<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>targetFile<span class="S10">.</span>time<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>sameCrc<span class="S0"> &nbsp;</span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S10">(</span>sourceFile<span class="S10">.</span>getCrc<span class="S10">()</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>targetFile<span class="S10">.</span>getCrc<span class="S10">())</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* display matched source-target pair and matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span>getNstcString<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>sameName<span class="S10">,</span><span class="S0"> </span>targetFile<span class="S10">.</span>sameSize<span class="S10">,</span><span class="S0"> </span>targetFile<span class="S10">.</span>sameTime<span class="S10">,</span><span class="S0"> </span>targetFile<span class="S10">.</span>sameCrc<span class="S10">));</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/******************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (3.1) SYNC TIME OF MATCHED TARGET FILE *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ******************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>targetFile<span class="S10">.</span>sameTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n Synchronizing last-modified time of matched target file\n &nbsp;"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceFile<span class="S10">.</span>getTimeString<span class="S10">());</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n Skipping last-modified time synchronization of matched target file"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnTimeSyncMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Synchronize last-modified time of matched target file\n &nbsp;"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceFile<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"?\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>choice<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>userCharPrompt<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" &nbsp;(Y)es/(N)o: "</span><span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"YN"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncTime<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>setFileTime<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">,</span><span class="S0"> </span>sourceFile<span class="S10">.</span>time<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>error<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to set last-modified time of matched target file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n "</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" ---&gt; "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceFile<span class="S10">.</span>getTimeString<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/************************************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * (3.2) RENAME MATCHED TARGET FILE *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ************************************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>targetFile<span class="S10">.</span>sameName<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n Renaming matched target file\n &nbsp;\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceFile<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'N'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printFlush<span class="S10">(</span><span class="S6">"\n\n Skipping renaming of matched target file"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>defaultActionOnRenameMatched<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'\0'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n Rename matched target file\n &nbsp;\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetFile<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>sourceFile<span class="S10">.</span>name<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"?\n"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">char</span><span class="S0"> </span>choice<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>userCharPrompt<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">" &nbsp;(Y)es/(N)o: "</span><span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"YN"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>choice<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S7">'Y'</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>syncName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>syncName<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(!</span>Sync<span class="S10">.</span>simulateOnly<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>File<span class="S0"> </span>newTarget<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">.</span>getParentFile<span class="S10">(),</span><span class="S0"> </span>sourceFile<span class="S10">.</span>name<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>String<span class="S0"> </span>error<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>SyncIO<span class="S10">.</span>renameFile<span class="S10">(</span>Sync<span class="S10">.</span>target<span class="S10">,</span><span class="S0"> </span>newTarget<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>error<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">!</span>error<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>reportWarning<span class="S10">(</span><span class="S6">"Failed to rename matched target file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\" ---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>newTarget<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\":\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>error<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S3">/*********************</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp;  * REPORT STATISTICS *</span><br />
<span class="S3">&nbsp; &nbsp; &nbsp; &nbsp;  *********************/</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n\n"</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>reportNumWarnings<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S4">1</span><span class="S10">)</span><span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S6">" warning"</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span><span class="S6">" warnings"</span><span class="S10">)</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">" encountered."</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Perform source-target file-matching.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> sFiles</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Source files to be matched</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> tFiles</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Target files (candidate matches)</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@return</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;True if matching is unique; false otherwise</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>performSourceTargetFileMatching<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sFiles<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>tFiles<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* return value */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">boolean</span><span class="S0"> </span>uniqueMatching<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>true<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* no source files to be matched? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sFiles<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S0"> </span>uniqueMatching<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* sort target files by "search" attributes for file-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Collections<span class="S10">.</span>sort<span class="S10">(</span>tFiles<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>searchFileUnitComparator<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* for each source file, find a matching target file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>MatchNextSourceFile<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sFiles<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Collections<span class="S10">.</span>binarySearch<span class="S10">(</span>tFiles<span class="S10">,</span><span class="S0"> </span>s<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>searchFileUnitComparator<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* no candidate match found */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>i<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>MatchNextSourceFile<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* candidate match found; proceed to find a valid matching target file */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">int</span><span class="S0"> </span>matchIndex<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">-</span><span class="S4">1</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>MatchNextTargetFileUp<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>j<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">1</span><span class="S10">;</span><span class="S0"> </span>j<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><span class="S0"> </span>j<span class="S10">--)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>t<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>tFiles<span class="S10">.</span>get<span class="S10">(</span>j<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>searchFileUnitComparator<span class="S10">.</span>compare<span class="S10">(</span>s<span class="S10">,</span><span class="S0"> </span>t<span class="S10">)</span><span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S0"> </span>MatchNextTargetFileUp<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to match last-modified time and CRC-32 checksum, if necessary */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>matchTime<span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>Math<span class="S10">.</span>abs<span class="S10">(</span>s<span class="S10">.</span>time<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span>t<span class="S10">.</span>time<span class="S10">)</span><span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S10">))</span><span class="S0"> </span><span class="S10">||</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">.</span>getCrc<span class="S10">()</span><span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>t<span class="S10">.</span>getCrc<span class="S10">()))))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>MatchNextTargetFileUp<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>matchIndex<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S10">(</span>t<span class="S10">.</span>match<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* the source or target file has already been matched */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>uniqueMatching<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>MatchNextTargetFileUp<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* valid matching target file found */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>matchIndex<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>j<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>MatchNextTargetFileDown<span class="S10">:</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">int</span><span class="S0"> </span>j<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>i<span class="S10">;</span><span class="S0"> </span>j<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span>tFiles<span class="S10">.</span>size<span class="S10">();</span><span class="S0"> </span>j<span class="S10">++)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>t<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>tFiles<span class="S10">.</span>get<span class="S10">(</span>j<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>searchFileUnitComparator<span class="S10">.</span>compare<span class="S10">(</span>s<span class="S10">,</span><span class="S0"> </span>t<span class="S10">)</span><span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S0"> </span>MatchNextTargetFileDown<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* proceed to match last-modified time and CRC-32 checksum, if necessary */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>Sync<span class="S10">.</span>matchTime<span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>Math<span class="S10">.</span>abs<span class="S10">(</span>s<span class="S10">.</span>time<span class="S0"> </span><span class="S10">-</span><span class="S0"> </span>t<span class="S10">.</span>time<span class="S10">)</span><span class="S0"> </span><span class="S10">&gt;</span><span class="S0"> </span>Sync<span class="S10">.</span>matchTimeTolerance<span class="S10">))</span><span class="S0"> </span><span class="S10">||</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">((</span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">.</span>getCrc<span class="S10">()</span><span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span>t<span class="S10">.</span>getCrc<span class="S10">()))))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>MatchNextTargetFileDown<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>matchIndex<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span><span class="S10">(</span>t<span class="S10">.</span>match<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* the source or target file has already been matched */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>uniqueMatching<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>false<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">continue</span><span class="S0"> </span>MatchNextTargetFileDown<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* valid matching target file found */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>matchIndex<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>j<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>matchIndex<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* valid matching target file found */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>t<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>tFiles<span class="S10">.</span>get<span class="S10">(</span>matchIndex<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>match<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>t<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>match<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* file-matching attributes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>sameName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">.</span>name<span class="S10">.</span>equals<span class="S10">(</span>t<span class="S10">.</span>name<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>sameSize<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">.</span>size<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>t<span class="S10">.</span>size<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>sameTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">.</span>time<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>t<span class="S10">.</span>time<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>sameCrc<span class="S0"> &nbsp;</span><span class="S10">=</span><span class="S0"> </span>Sync<span class="S10">.</span>matchCrc<span class="S0"> </span><span class="S10">?</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">.</span>getCrc<span class="S10">()</span><span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>t<span class="S10">.</span>getCrc<span class="S10">())</span><span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>false<span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>sameName<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">.</span>sameName<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>sameSize<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">.</span>sameSize<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>sameTime<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">.</span>sameTime<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>sameCrc<span class="S0"> &nbsp;</span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">.</span>sameCrc<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S0"> </span>uniqueMatching<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Perform source-target directory-matching (matching by name only).</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> sDirs</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Source subdirectories to be matched</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> tDirs</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Target subdirectories (candidate matches)</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>performSourceTargetDirMatching<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>sDirs<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FileUnit<span class="S10">&gt;</span><span class="S0"> </span>tDirs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* no source subdirectories to be matched? */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>sDirs<span class="S10">.</span>isEmpty<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S10">;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* sort target directories by name only for directory-matching */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Collections<span class="S10">.</span>sort<span class="S10">(</span>tDirs<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>nameOnlyFileUnitComparator<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* for each source subdirectory, find a matching target subdirectory */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FileUnit<span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sDirs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">int</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>Collections<span class="S10">.</span>binarySearch<span class="S10">(</span>tDirs<span class="S10">,</span><span class="S0"> </span>s<span class="S10">,</span><span class="S0"> </span>Sync<span class="S10">.</span>nameOnlyFileUnitComparator<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>i<span class="S0"> </span><span class="S10">&gt;=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* valid matching target directory found */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FileUnit<span class="S0"> </span>t<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>tDirs<span class="S10">.</span>get<span class="S10">(</span>i<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>match<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>t<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>t<span class="S10">.</span>match<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>s<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Determine sequence of actual rename operations to be performed, in order</span><br />
<span class="S3">&nbsp; &nbsp;  * to effect the desired rename operations.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> renamePairs</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Desired rename operations</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@return</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Sequence of actual rename operations to be performed</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>List<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>getRenameOperations<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>renamePairs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* determine target files, check validity, and detect clashes */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Map<span class="S10">&lt;</span>File<span class="S10">,</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>targetMap<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TreeMap<span class="S10">&lt;</span>File<span class="S10">,</span>FilePair<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FilePair<span class="S0"> </span>p<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>renamePairs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* check for clash (i.e. nonunique target filenames) */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>q<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>targetMap<span class="S10">.</span>get<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>q<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetMap<span class="S10">.</span>put<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">,</span><span class="S0"> </span>p<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"(INTERNAL) Target filename clash:\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"[1] \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>q<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n &nbsp;---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>q<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"[2] \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>p<span class="S10">.</span>source<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"\n &nbsp;---&gt; \""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>p<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* determine actual renaming sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Map<span class="S10">&lt;</span>File<span class="S10">,</span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;&gt;</span><span class="S0"> </span>sequenceHeads<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TreeMap<span class="S10">&lt;</span>File<span class="S10">,</span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Map<span class="S10">&lt;</span>File<span class="S10">,</span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;&gt;</span><span class="S0"> </span>sequenceTails<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TreeMap<span class="S10">&lt;</span>File<span class="S10">,</span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>FilePair<span class="S0"> </span>p<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>renamePairs<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* look for a sequence head with source = this target */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>headSequence<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sequenceHeads<span class="S10">.</span>get<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* look for a sequence tail with target = this source */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>tailSequence<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>sequenceTails<span class="S10">.</span>get<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>headSequence<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>tailSequence<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* add this file rename pair as a new sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>add<span class="S10">(</span>p<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>put<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>s<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>put<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">,</span><span class="S0"> </span>s<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>headSequence<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>tailSequence<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* add this pair to the head of an existing sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>headSequence<span class="S10">.</span>addFirst<span class="S10">(</span>p<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>put<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>headSequence<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>headSequence<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>tailSequence<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* add this pair to the tail of an existing sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tailSequence<span class="S10">.</span>addLast<span class="S10">(</span>p<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>put<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">,</span><span class="S0"> </span>tailSequence<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><span class="S0"> </span><span class="S5">if</span><span class="S0"> </span><span class="S10">((</span>headSequence<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><span class="S0"> </span><span class="S10">&amp;&amp;</span><span class="S0"> </span><span class="S10">(</span>tailSequence<span class="S0"> </span><span class="S10">!=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>headSequence<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span>tailSequence<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* loop detected, so we use a temporary target file/directory name */</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* create a temporary file/directory name */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>File<span class="S0"> </span>temp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">.</span>getParentFile<span class="S10">(),</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>target<span class="S10">.</span>getName<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">".sync"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>temp<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>targetMap<span class="S10">.</span>containsKey<span class="S10">(</span>temp<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span><span class="S5">long</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;</span><span class="S0"> </span>i<span class="S0"> </span><span class="S10">&lt;</span><span class="S0"> </span>Long<span class="S10">.</span>MAX_VALUE<span class="S10">;</span><span class="S0"> </span>i<span class="S10">++)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>temp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>File<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">.</span>getParentFile<span class="S10">(),</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>target<span class="S10">.</span>getName<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">".sync."</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>i<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>temp<span class="S10">.</span>exists<span class="S10">()</span><span class="S0"> </span><span class="S10">||</span><span class="S0"> </span>targetMap<span class="S10">.</span>containsKey<span class="S10">(</span>temp<span class="S10">))</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>temp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">null</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* use this unused name */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">break</span><span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>temp<span class="S0"> </span><span class="S10">==</span><span class="S0"> </span><span class="S5">null</span><span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throw</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>TerminatingException<span class="S10">(</span><span class="S6">"Ran out of suffixes for temporary name of file \""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>p<span class="S10">.</span>target<span class="S10">.</span>getPath<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\"."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* use this unused filename */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>targetMap<span class="S10">.</span>put<span class="S10">(</span>temp<span class="S10">,</span><span class="S0"> </span><span class="S5">null</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* add a leading and trailing rename file pair to the existing sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>tempTail<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">,</span><span class="S0"> </span>temp<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>FilePair<span class="S0"> </span>tempHead<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>FilePair<span class="S10">(</span>temp<span class="S10">,</span><span class="S0"> </span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>headSequence<span class="S10">.</span>addFirst<span class="S10">(</span>tempHead<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tailSequence<span class="S10">.</span>addLast<span class="S10">(</span>tempTail<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>put<span class="S10">(</span>temp<span class="S10">,</span><span class="S0"> </span>headSequence<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>put<span class="S10">(</span>temp<span class="S10">,</span><span class="S0"> </span>tailSequence<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* link two distinct sequences together */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tailSequence<span class="S10">.</span>addLast<span class="S10">(</span>p<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>tailSequence<span class="S10">.</span>addAll<span class="S10">(</span>headSequence<span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceHeads<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>target<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>remove<span class="S10">(</span>p<span class="S10">.</span>source<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>sequenceTails<span class="S10">.</span>put<span class="S10">(</span>tailSequence<span class="S10">.</span>peekLast<span class="S10">().</span>target<span class="S10">,</span><span class="S0"> </span>tailSequence<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* prepare return value */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>List<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>renameOperations<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>ArrayList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>LinkedList<span class="S10">&lt;</span>FilePair<span class="S10">&gt;</span><span class="S0"> </span>s<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>sequenceHeads<span class="S10">.</span>values<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* get reversed order of rename file pairs within the sequence */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Collections<span class="S10">.</span>reverse<span class="S10">(</span>s<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>renameOperations<span class="S10">.</span>addAll<span class="S10">(</span>s<span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S0"> </span>renameOperations<span class="S10">;</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Return string representation of match attributes, e.g. "(name,size,time,crc)".</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>getNstcString<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>n<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>s<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>t<span class="S10">,</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span><span class="S5">boolean</span><span class="S0"> </span>c<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>StringBuilder<span class="S0"> </span>a<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>StringBuilder<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S7">'('</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>n<span class="S10">)</span><span class="S0"> </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"name,"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>s<span class="S10">)</span><span class="S0"> </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"size,"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>t<span class="S10">)</span><span class="S0"> </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"time,"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>c<span class="S10">)</span><span class="S0"> </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"crc,"</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>a<span class="S10">.</span>deleteCharAt<span class="S10">(</span>a<span class="S10">.</span>length<span class="S10">()</span><span class="S0"> </span><span class="S10">-</span><span class="S0"> </span><span class="S4">1</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>a<span class="S10">.</span>append<span class="S10">(</span><span class="S7">')'</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S0"> </span>a<span class="S10">.</span>toString<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Print a warning message and pause.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> message</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Warning message to be printed on issuing the warning</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>reportWarning<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Object<span class="S0"> </span>message<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>Sync<span class="S10">.</span>reportNumWarnings<span class="S10">++;</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">if</span><span class="S0"> </span><span class="S10">(</span>Sync<span class="S10">.</span>ignoreWarnings<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printToErr<span class="S10">(</span><span class="S6">"\n\nWARNING: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>message<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">else</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>printToErr<span class="S10">(</span><span class="S6">"\n\nWARNING: "</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>message<span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\nPress ENTER to continue..."</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">(</span><span class="S5">new</span><span class="S0"> </span>Scanner<span class="S10">(</span>System<span class="S10">.</span>in<span class="S10">)).</span>nextLine<span class="S10">();</span><span class="S0"> </span><span class="S2">// blocks until user responds</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Get custom exception message string for the given exception.</span><br />
<span class="S3">&nbsp; &nbsp;  * Message contains the exception class name, error description string,</span><br />
<span class="S3">&nbsp; &nbsp;  * and stack trace.</span><br />
<span class="S3">&nbsp; &nbsp;  *</span><br />
<span class="S3">&nbsp; &nbsp;  * </span><span class="S18">@param</span><span class="S3"> e</span><br />
<span class="S3">&nbsp; &nbsp;  * &nbsp;&nbsp;&nbsp;&nbsp;Exception for which to generate the custom message string</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">static</span><span class="S0"> </span>String<span class="S0"> </span>getExceptionMessage<span class="S10">(</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>Exception<span class="S0"> </span>e<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">final</span><span class="S0"> </span>StringBuilder<span class="S0"> </span>s<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>StringBuilder<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\nJava exception information ("</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>e<span class="S10">.</span>getClass<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"):\n\""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>e<span class="S10">.</span>getMessage<span class="S10">()</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"\""</span><span class="S10">);</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">for</span><span class="S0"> </span><span class="S10">(</span>StackTraceElement<span class="S0"> </span>t<span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>e<span class="S10">.</span>getStackTrace<span class="S10">())</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S6">"\n &nbsp;at "</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span>t<span class="S10">.</span>toString<span class="S10">());</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>s<span class="S10">.</span>append<span class="S10">(</span><span class="S7">'\n'</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">return</span><span class="S0"> </span>s<span class="S10">.</span>toString<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<br />
<br />
<span class="S0">&nbsp; &nbsp; </span><span class="S3">/**</span><br />
<span class="S3">&nbsp; &nbsp;  * Print usage documentation.</span><br />
<span class="S3">&nbsp; &nbsp;  */</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S5">private</span><span class="S0"> </span><span class="S5">static</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>printUsage<span class="S10">()</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* RULER &nbsp;&nbsp;00000000011111111112222222222333333333344444444445555555555666666666677777777778 */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S1">/* RULER &nbsp;&nbsp;12345678901234567890123456789012345678901234567890123456789012345678901234567890 */</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span>SyncIO<span class="S10">.</span>print<span class="S10">(</span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nSync performs one-way directory or file synchronization."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nUSAGE: &nbsp;java -jar Sync.jar &nbsp;&lt;switches&gt; &nbsp;[\"Source\"] &nbsp;[\"Target\"]"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nSynchronize [\"Target\"] to match [\"Source\"]. Only [\"Target\"] is modified."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nBy default, the filename, size, last-modified time, and CRC-32 checksum"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nare used for file-matching. The synchronization mode depends on [\"Source\"]:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n [\"Source\"] is a DIRECTORY: Match source and target directories recursively."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;Matched target files are time-synced and renamed if necessary,"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;unmatched source files are copied to the target directory, and"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;unmatched target files/directories are deleted."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n [\"Source\"] is a FILE: Match source and target files, ignoring filename."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;If files match, then the target file is time-synced and renamed if necessary."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;If target file does not exist, then the source file is copied to the target."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n&lt;Switches&gt;:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -s, --simulate &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Simulate only; do not modify target"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--ignorewarnings &nbsp;Ignore warnings; do not pause"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -l, --log:&lt;\"x\"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create log file x; if x is not specified,"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"sync.yyyyMMdd-HHmmss.log\" is used"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -r, --norecurse &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not recurse into subdirectories"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -n, --noname &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not use filename for file-matching"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -t, --notime &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not use last-modified time for file-matching"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -c, --nocrc &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not use CRC-32 checksum for file-matching"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--time:[x] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Use a x-millisecond time-tolerance for file-matching"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(0-millisecond time-tolerance is used by default;"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use --time:1000 or more to avoid mismatches across"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;different file systems)"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--rename:[y|n] &nbsp;&nbsp;&nbsp;Always[y]/never[n] rename matched target files"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--synctime:[y|n] &nbsp;... synchronize time of matched target files"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--overwrite:[y|n] ... overwrite existing target files/directories"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--delete:[y|n] &nbsp;&nbsp;&nbsp;... delete unmatched target files/directories"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;--force &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Equivalent to the combination:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--rename:y --synctime:y --overwrite:y --delete:y"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n A subset of source and/or target files/directories can be selected for"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n synchronization using GLOB (or REGEX) filename filters. A file/directory is"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n selected if it matches any of the \"include\" filters and none of the \"exclude\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n filters."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -i, &nbsp;--include:[\"x\"] &nbsp;&nbsp;Include source and target files/directories with names"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matching GLOB expression x"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -x, &nbsp;--exclude:[\"x\"] &nbsp;&nbsp;Exclude source and target files/directories with names"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matching GLOB expression x"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -is, --includesource:[\"x\"] &nbsp;&nbsp;Include source files/directories ..."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -xs, --excludesource:[\"x\"] &nbsp;&nbsp;Exclude source files/directories ..."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -it, --includetarget:[\"x\"] &nbsp;&nbsp;Include target files/directories ..."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -xt, --excludetarget:[\"x\"] &nbsp;&nbsp;Exclude target files/directories ..."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -p, &nbsp;--path &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Filter relative pathnames instead of filenames"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(e.g. \"work\\report\\jan.txt\" instead of \"jan.txt\")"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n -w, &nbsp;--lower &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Use lower case names for filtering"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(e.g. \"HelloWorld2007.JPG\" ---&gt; \"helloworld2007.jpg\")"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--regex &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Use REGEX instead of GLOB filename filters"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(see Java API for REGEX syntax)"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GLOB syntax:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* &nbsp;&nbsp;&nbsp;Match a string of 0 or more characters"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? &nbsp;&nbsp;&nbsp;Match exactly 1 character"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ ] &nbsp;&nbsp;Match exactly 1 character inside the brackets:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[abc] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;match a, b, or c"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[!abc] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;match any character except a, b, or c (negation)"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[a-z0-9] &nbsp;&nbsp;&nbsp;match any character a through z, or 0 through 9,"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inclusive (range)"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ } &nbsp;&nbsp;Match exactly 1 comma-delimited string inside the braces:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{a,bc,def} &nbsp;match either a, bc, or def"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To use a construct symbol (e.g. [, {, ?) as a literal character,"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert a backslash before it, e.g. use \\[ for the literal character [."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Use \\\\ for the literal backslash character \\."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The file separator in Windows can be specified by \\\\ or /."</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\nEXAMPLES:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 1. Synchronize target \"C:\\Backup\" to look like source \"C:\\Original\","</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;matching files by (name,size,time,crc):"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar \"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 2. As in example 1, but never delete unmatched target files/directories:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar --delete:n \"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 3. As in example 1, but match files by (name,size,time) with a time-tolerance"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;of 2 seconds instead:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar --nocrc --time:2000 \"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 4. As in example 1, but always rename and synchronize time of matched target"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;files, overwrite existing target files, and delete unmatched target"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;files/directories:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar --force \"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 5. As in example 1, but synchronize only jpg and html files:"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar --include:\"*.{jpg,html}\" \"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n 6. As in example 5, but skip files that begin with a tilde '~':"</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;java -jar Sync.jar --include:\"*.{jpg,html}\" --exclude:\"~*\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n &nbsp;&nbsp;&nbsp;&nbsp;\"C:\\Original\" \"C:\\Backup\""</span><span class="S0"> </span><span class="S10">+</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S6">"\n\n"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S10">}</span><br />
<span class="S0"></span></span>
</body>
</html>
